package com.example.service;

import com.example.pojo.Person;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

/**
 * @author およそ神
 * @version JDK 1.8
 * Hystrix服务降级 ~
 */
//@Component
public class PersonClientServiceFallBackFactory implements FallbackFactory {
    @Override
    public PersonClientService create(Throwable cause) {
        return new PersonClientService() {
            @Override
            public Boolean addPerson(Person person) {
                return null;
            }

            /**
             * 熔断处理
             * @param id
             * @return
             */
            @Override
            public Person searchById(Integer id) {
                return new Person().setId(id)
                        .setName("熔断处理---->没有找到姓名")
                        .setAge(666)
                        .setUpdateby("凡总神")
                        .setTest("test成功!");
            }

            @Override
            public List<Person> searchAll() {
                return null;
            }
        };
    }
}
